package com.ceair.flight.refund.location.dt.enums;

/**
 * 退票原因枚举类: 20以前的简码值代表自愿, 20以后为非自愿退票
 *
 * @author youguilin
 */
public enum RefundReasonEnum {
    PERSONAL("10", true, "由于自身原因无法成行, 同意扣除退票手续费退票"),
    FLIGHT_RESCHEDULE("21", false, "由于航空公司原因, 无法成行, 申请全额退票"),
    SICK_DEATH("22", false, "由于乘机人因病(身故), 无法成行, 申请全额退票"),
    REBOUGHT("23", false, "重购相同客票且已使用, 申请全额退票"),
    OTHERS("24", false, "其它(拒签, 系统问题)"),
    REFUND_IN_24H("25", false, "出票后24小时内退票"),
    REFUND_BEFORE_24H("26", false, "韩国当天退票"),
    RISK_CHECK_FAILED("50", false, "风控审核失败(Risk control check failed)"),
    USER_REFUSE_PAY("51", false, "用户拒绝支付(User refuse pay)");

    /**
     * 简码
     */
    private final String code;

    /**
     * 是否是自愿退票
     */
    private final boolean voluntary;

    /**
     * 描述
     */
    private final String description;

    private RefundReasonEnum(String code, boolean voluntary, String description) {
        this.code = code;
        this.voluntary = voluntary;
        this.description = description;
    }

    /**
     * @return Returns the code.
     */
    public String getCode() {
        return code;
    }

    /**
     * @return Returns the description.
     */
    public String getDescription() {
        return description;
    }

    /**
     * 通过枚举<code>code</code>获得枚举。
     *
     * @param code 简码
     * @return 枚举
     */
    public static RefundReasonEnum getByCode(String code) {
        for (RefundReasonEnum status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }

    public boolean isVoluntary() {
        return voluntary;
    }

}
